import sys
import whisper

if len(sys.argv) < 2:
    print("Usage: python transcribe.py <audio_file>")
    sys.exit(1)

audio_path = sys.argv[1]

try:
    model = whisper.load_model("base")  # 可选 small, medium, large
    result = model.transcribe(audio_path, language='zh')  # 指定中文识别更精准
    print(result["text"])
except Exception as e:
    print(f"Error: {e}", file=sys.stderr)
    sys.exit(1)
